# -*- coding=utf-8
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
import sys
import os
import logging
from tools import cos

# 临时密钥的 SecretId，临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
tmp_secret_id = 'AKID51kmqhKAoIbicLwPefU8ulTzJQJ0Tirp'
# 临时密钥的 SecretKey，临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
tmp_secret_key = 'tZ0DE2e2EE1b1CAvSmtoY6TcYFj27yc9'

region = 'ap-chengdu'  # 替换为用户的 region，已创建桶归属的 region 可以在控制台查看，https://console.cloud.tencent.com/cos5/bucket
# COS 支持的所有 region 列表参见https://cloud.tencent.com/document/product/436/6224
scheme = 'https'  # 指定使用 http/https 协议来访问 COS，默认为 https，可不填

config = CosConfig(Region=region, SecretId=tmp_secret_id, SecretKey=tmp_secret_key, Scheme=scheme)
client = CosS3Client(config)

# response = client.upload_file(
#     Bucket='test-1360779007',
#     LocalFilePath='D:/tracer/tools/cloud.png',
#     Key='test.jpg',
# )
# print(response['ETag'])

# SecretId:AKID51kmqhKAoIbicLwPefU8ulTzJQJ0Tirp
# SecretKey:tZ0DE2e2EE1b1CAvSmtoY6TcYFj27yc9


client.delete_object(
    Bucket='test-1360779007',
    Key='test.jpg'
)